import equals from '../utils/equals'
export const state = () => ({
  userInfo: {},
  historyList: []
})

export const mutations = {
  setUserInfo (state, data) {
    state.userInfo = data
  },
  addHistory (state, data) {
    let isEqual = true
    for (let i = 0; i < state.historyList.length; i++) {
      if (equals(state.historyList[i], data)) {
        isEqual = false
        break
      }
    }
    if (isEqual) {
      state.historyList.unshift(data)
    }
  }
}
